package net.phoenix.repository.property;

import javax.jcr.RepositoryException;
import javax.jcr.Value;
import javax.jcr.nodetype.PropertyDefinition;

import net.phoenix.repository.BasicNode;

/**
 * 
 * Jigsaw server
 * 
 * @author <a href="shamphone@gmail.com">Li XiongFeng</a>
 * @date 2012-1-3
 * @version 1.0.0
 */
public class LongProperty extends BasicProperty {
	/**
	 * create single value property
	 * 
	 * @param node
	 * @param definition
	 * @param value
	 */
	public LongProperty(BasicNode node, PropertyDefinition definition, Value value) {
		super(node, definition, value);

	}

	/**
	 * create multiple values property
	 * 
	 * @param node
	 * @param definition
	 * @param values
	 */
	public LongProperty(BasicNode node, PropertyDefinition definition, Value[] values) {
		super(node, definition, values);
	}

	/**
	 * create a property with default value;
	 * 
	 * @param node
	 * @param definition
	 */
	public LongProperty(BasicNode node, PropertyDefinition definition) {
		super(node, definition);

	}

//	@Override
//	public void index(Document document) throws RepositoryException {
//		PropertyDefinition definition =  this.getDefinition();
//		if(definition.isFullTextSearchable()){
//			for(Value value: this.values){
//				document.add(new Field(definition.getName(),NumericUtils.longToPrefixCoded(value.getLong()), Field.Store.YES, Field.Index.NOT_ANALYZED));
//			}
//		}
//	}
	
	@Override
	public void setValue(double value) throws RepositoryException {
		super.setValue(this.getValueFactory().createValue((long)value));
	}
	
	@Override
	public void setValue(long value) throws RepositoryException {
		super.setValue(this.getValueFactory().createValue(value));
	}
}
